@echo off
REM 声明采用UTF-8编码
chcp 65001

echo "Start release script..."

::echo "input branch"
::set /p branch=
::echo "branch: %branch%"

::echo "input new branch"
::set /p new_branch=
::echo "new branch: %new_branch%"

:: 2、执行检出新分支迭代
echo "===> 正在从远程分支/%branch%建立新分支%new_branch%"
call git -c core.quotepath=false -c log.showSignature=false checkout -b %new_branch% origin/%branch%
:: 3、新分支打上快照
call mvn versions:set -DnewVersion=%new_branch%-SNAPSHOT -DgenerateBackupPoms=false

:: 4、推送新分支至远程，升级结束
echo "===> 正在将新分支%new_branch%推送至远程仓库"
call git add .
call git commit -m "[update]%branch%版本发布，更新POM版本到%new_branch%-SNAPSHOT"
call git push -u origin %new_branch%

:: remove SNAPSHOT
echo "===> remove snapshot"
call git -c core.quotepath=false -c log.showSignature=false checkout -B %branch% origin/%branch% --
:: 1、当前分支拉取代码
:: call %fetch%
:: 2、移除快照
call mvn versions:set -DnewVersion=%branch% -DgenerateBackupPoms=false
:: 3、推送分支
call git add .
call git commit -m "[update]%branch%版本去快照"
call git push -u origin %branch%

pause